import { cloudService } from './index'
import { IKpi, IKpiQuery } from '@/types/kpi'

export const addKpiApi = (kpi: IKpi): Promise<boolean> =>
  cloudService({
    url: '/home-api/kpi',
    method: 'post',
    data: kpi
  })

export const updateKpiApi = (id: number, kpi: IKpi): Promise<boolean> =>
  cloudService({
    url: `/home-api/kpi/${id}`,
    method: 'put',
    data: kpi
  })

export const deleteKpiApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/home-api/kpi/${id}`,
    method: 'delete'
  })

export const queryKpiApi = (query: IKpiQuery): Promise<IKpi[]> =>
  cloudService({
    url: '/home-api/kpi',
    method: 'get',
    params: { ...query }
  })
